import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useRouterStore = defineStore('routerStore', () => {

  const routes = ref<any[]>([])

  const cleanRoutes = () => routes.value = []

  const pushRoutes = (route: any) => {
    routes.value.push(route)
  }

  const setRoutes = (route: any[]) => {
    routes.value = route
  }

  return {
   routes,
   pushRoutes,
   cleanRoutes,
   setRoutes
  }
  
}, {
  persist: {
    storage: {
      getItem: (key) => uni.getStorageSync(key),  
      setItem: (key, val) => uni.setStorageSync(key, val)
    }
  }
})